package com.qf.service.impl;

import com.qf.entity.Address;
import com.qf.mapper.AddressMapper;
import com.qf.service.IAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class AddressServiceImpl implements IAddressService {

    @Autowired
    private AddressMapper addressMapper;

    @Override
    public Address selectByUid(int uId) {
        return addressMapper.selectByUid(uId);
    }

    @Override
    public List<Address> selectAddress(int uId) {
        return addressMapper.selectAddress(uId);
    }

    /**
     * 更改默认地址
     * @param aId
     * @return
     */

    @Override
    @Transactional
    public int updateAddress(int aId,int uId) {
        addressMapper.defaultAddress(uId);
        addressMapper.updateAddress(aId);
        return 1;
    }


}
